#include <iostream>


using namespace std;
const int N = 1e5 + 5;

int arr[N];

signed main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++ i) {
        scanf("%d", arr + i);
        arr[i] += arr[i - 1];
    }
    while (m --) {
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d\n", arr[b] - arr[a - 1]);
    }
    return 0;
}